package tp.pr4.gui;

import java.awt.BorderLayout;
import javax.swing.JPanel;

import tp.pr4.RobotEngine;

public class NavigationPanel extends JPanel {
	private RobotEngine rbt;
	private LogView bot;
	private RobotHeading left;
	private MapView right;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Main constructor
	 */
	public NavigationPanel(RobotEngine rbt){
		this.rbt = rbt;
		/*
		 * Adds the components in the navigationpanel component
		 */
		this.setLayout(new BorderLayout());
		init();
	}
	/**
	 * Creates the components inside the panel
	 */
	private void init(){
		/*
		 * Creates the first layer panel
		 */
		JPanel top_center = new JPanel();
		top_center.setLayout(new BorderLayout());
		
		
		left = new RobotHeading(rbt);
		bot = new LogView(rbt);
		right = new MapView(rbt, bot);
			/*
			 * Adds the robot image panel
			 */			
			top_center.add(left, BorderLayout.WEST);
			/*
			 * Adds the log section
			 */			
			this.add(bot,BorderLayout.SOUTH);
			/*
			 * Adds the map view panel
			 */			
			top_center.add(right, BorderLayout.CENTER);
			/*
			 * Adds the full content
			 */
			this.add(top_center,BorderLayout.CENTER);
			
	}
	
	/**
	 * Refreshes the gui
	 */
	public void refresh(){
		bot.refresh();
		left.refresh();
		/*
		 * sets the new place active (if moved)
		 */
		right.refreshCellsState();
	}
	
	/**
	 * Returns the map panel
	 */
	public MapView getMap(){
		return this.right;
	}
	
}
